package com.itheima.dao;

import com.itheima.pojo.Order;
import com.itheima.pojo.OrderSetting;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface OrdersettingDao {
    @Select("select count(*) from t_ordersetting where orderDate=#{orderDate}")
    long findCountByTime(OrderSetting orderSetting);
    @Update("update t_ordersetting set number=#{number} where orderDate=#{orderDate}")
    void editNumberBYTime(OrderSetting orderSetting);
     @Insert("insert into t_ordersetting(number,orderDate,reservations) values(#{number},#{orderDate},0)")
    void insertOrdersetting(OrderSetting orderSetting);
     @Select("select orderDate,number,reservations FROM t_ordersetting WHERE YEAR(orderdate)=#{year} and MONTH(orderdate)=#{month}")
    List<OrderSetting> find(@Param("year") String year, @Param("month") String month);
    @Select("select * from  t_ordersetting where orderDate=#{date}")
    OrderSetting findByDate(String date);
    @Select("select * from  t_order where member_id=#{vipId} and setmeal_id=#{setmealId}")
    OrderSetting findByIdAndSetmealId(@Param("vipId") Integer vipId, @Param("setmealId") String setmealId);
    @Insert("insert into t_order (member_id,orderDate,orderType,orderStatus,setmeal_id) values (#{memberId},#{orderDate},#{orderType},#{orderStatus},#{setmealId})")
    @Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    void saveOrder(Order orderInfo);

     @Update("update t_ordersetting  set reservations=reservations+1 where orderDate = #{orderDate}")
    void editReservations(String orderDate);
}
